/********************************************************************
Name: Table A14: Effect of Democratic Sheriff on Alternative Versions
	of Detention Outcomes
Author: Dan Thompson
Date: August 2019
Notes:
********************************************************************/

* Set the working directory 
gl root = "$sanctuary_root"
gl root = "YOUR_WORKING_DIRECTORY"

* Bring in the RD analysis data
use "$root/data/rd analysis data.dta", clear
egen year_by_pre_year_id = group(year pre_year)

* Column 1
reg all_sheriff_per1k_pop treat rv treat_rv ///
	if abs(rv)<10, vce(clust election_id)
reg all_sheriff_per1k_fb treat rv treat_rv ///
	if abs(rv)<10, vce(clust election_id)
reg log_all_sheriff treat rv treat_rv ///
	if abs(rv)<10, vce(clust election_id)

* Column 2
reg all_sheriff_per1k_pop treat rv rv2 rv3 ///
	if abs(rv)<25, vce(clust election_id)
reg all_sheriff_per1k_fb treat rv rv2 rv3 ///
	if abs(rv)<25, vce(clust election_id)
reg log_all_sheriff treat rv rv2 rv3 ///
	if abs(rv)<25, vce(clust election_id)

* Column 3
reg all_sheriff_per1k_pop treat rv rv2 rv3 treat_rv treat_rv2 treat_rv3 ///
	if abs(rv)<25, vce(clust election_id)
reg all_sheriff_per1k_fb treat rv rv2 rv3 treat_rv treat_rv2 treat_rv3 ///
	if abs(rv)<25, vce(clust election_id)
reg log_all_sheriff treat rv rv2 rv3 treat_rv treat_rv2 treat_rv3 ///
	if abs(rv)<25, vce(clust election_id)

* Column 4
reg all_sheriff_per1k_pop treat rv rv2 rv3 rv4 rv5 ///
	if abs(rv)<25, vce(clust election_id)
reg all_sheriff_per1k_fb treat rv rv2 rv3 rv4 rv5 ///
	if abs(rv)<25, vce(clust election_id)
reg log_all_sheriff treat rv rv2 rv3 rv4 rv5 ///
	if abs(rv)<25, vce(clust election_id)

* Column 5
reg all_sheriff_per1k_pop treat rv treat_rv ///
	i.year_by_pre_year_id##c.pre_all_sheriff_per1k_pop ///
	if abs(rv)<10, vce(clust election_id)
reg all_sheriff_per1k_fb treat rv treat_rv ///
	i.year_by_pre_year_id##c.pre_all_sheriff_per1k_fb ///
	if abs(rv)<10, vce(clust election_id)
reg log_all_sheriff treat rv treat_rv ///
	i.year_by_pre_year_id##c.pre_log_all_sheriff ///
	if abs(rv)<10, vce(clust election_id)

* Column 6
reg all_sheriff_per1k_pop treat rv rv2 rv3 ///
	i.year_by_pre_year_id##c.pre_all_sheriff_per1k_pop ///
	if abs(rv)<25, vce(clust election_id)
reg all_sheriff_per1k_fb treat rv rv2 rv3 ///
	i.year_by_pre_year_id##c.pre_all_sheriff_per1k_fb ///
	if abs(rv)<25, vce(clust election_id)
reg log_all_sheriff treat rv rv2 rv3 ///
	i.year_by_pre_year_id##c.pre_log_all_sheriff ///
	if abs(rv)<25, vce(clust election_id)

* Column 7
reg all_sheriff_per1k_pop treat rv rv2 rv3 treat_rv treat_rv2 treat_rv3 ///
	i.year_by_pre_year_id##c.pre_all_sheriff_per1k_pop ///
	if abs(rv)<25, vce(clust election_id)
reg all_sheriff_per1k_fb treat rv rv2 rv3 treat_rv treat_rv2 treat_rv3 ///
	i.year_by_pre_year_id##c.pre_all_sheriff_per1k_fb ///
	if abs(rv)<25, vce(clust election_id)
reg log_all_sheriff treat rv rv2 rv3 treat_rv treat_rv2 treat_rv3 ///
	i.year_by_pre_year_id##c.pre_log_all_sheriff ///
	if abs(rv)<25, vce(clust election_id)

* Column 8
reg all_sheriff_per1k_pop treat rv rv2 rv3 rv4 rv5 ///
	i.year_by_pre_year_id##c.pre_all_sheriff_per1k_pop ///
	if abs(rv)<25, vce(clust election_id)
reg all_sheriff_per1k_fb treat rv rv2 rv3 rv4 rv5 ///
	i.year_by_pre_year_id##c.pre_all_sheriff_per1k_fb ///
	if abs(rv)<25, vce(clust election_id)
reg log_all_sheriff treat rv rv2 rv3 rv4 rv5 ///
	i.year_by_pre_year_id##c.pre_log_all_sheriff ///
	if abs(rv)<25, vce(clust election_id)

* Column 9
rdrobust all_sheriff_per1k_pop rv, vce(cluster election_id)
rdrobust all_sheriff_per1k_fb rv, vce(cluster election_id)
rdrobust log_all_sheriff rv, vce(cluster election_id)

